let accountModel = require("../models/account").accountList;

let accountDAO = function (){};

accountDAO.prototype = {
  //增
  save: function (json, callBack){
    let newAccount = new accountModel(json);
    newAccount.save(function (err){
      callBack(err);
    });
  },
  // //删
  remove: function (json, callBack){
    accountModel.remove(json, function (err){
      callBack(err);
    });
  },
  // //改
  update: function (json, condition, callBack){
    accountModel.update(json, condition, function (err){
      callBack(err);
    });
  },
  //查询列表
  findById: function (id, callBack){
    accountModel.find({userId: id},{accountName:1,account:1,accountPassword:1,children:1,superiorId:1}, function (err, doc){
      callBack(err, doc);
    });
  },
  //查询单个
  findOneById: function (id, callBack){
    accountModel.findOne({_id: id}, function (err, doc){
      callBack(err, doc);
    });
  }
};

exports.accountMethod = new accountDAO();
